package com.xy.biz.xd.domain.bo;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class DocumentFlowConstants extends DocumentFlowBO {

    public final static String VARIABLE_ASSIGNEE_LIST = "assigneeList";
    public final static String VARIABLE_ASSIGNEE = "assignee";
    public final static String VARIABLE_HANDLE = "handle";

    public final static String PROCESS_NEW_FLOW = "newProcess";
    public final static String PROCESS_COMMON_FLOW = "commonProcess";
    public final static String PROCESS_CANCEL_REQUEST = "cancelRequestProcess";

    public final static int HANDLE_RESULT_FINISH_FLOW = 0;
    public final static int HANDLE_RESULT_ACCEPT = 1;
    public final static int HANDLE_RESULT_REJECT = 2;
    public final static int HANDLE_RESULT_END = 3;
    public final static int HANDLE_RESULT_CANCEL = 4;

    public final static String URGENT_NORMAL = "0";
    public final static String URGENT_URGENT = "1";

    public final static int TRAIN_CHECK_STATUS_UNCHECK = 0;
    public final static int TRAIN_CHECK_STATUS_CHECK = 1;
    public final static int TRAIN_CHECK_STATUS_START = 2;

    /**
     * 流程类型-新增流程
     */
    public final static int FLOW_TYPE_NEW = 1;
    /**
     * 流程类型-修订流程
     */
    public final static int FLOW_TYPE_MODIFY = 2;
    /**
     * 流程类型-作废流程
     */
    public final static int FLOW_TYPE_DROP = 3;
    /**
     * 流程类型-下载审批流程
     */
    public final static int FLOW_TYPE_DOWNLOAD = 4;
    /**
     * 流程类型-借阅流程
     */
    public final static int FLOW_TYPE_BORROW = 5;
    /**
     * 流程类型-取消申请流程
     */
    public final static int FLOW_TYPE_CANCEL_REQUEST = 6;

    /**
     * 状态-申请
     */
    public final static String PHASE_APPLY = "newApply";
    /**
     * 状态-申请审批
     */
    public final static String PHASE_APPLY_APPROVAL= "applyApproval";
    /**
     * 状态-上传文件
     */
    public final static String PHASE_UPLOAD = "adminAudit";
    /**
     * 状态-编辑
     */
    public final static String PHASE_EDIT = "draft";
    /**
     * 状态-评审
     */
    public final static String PHASE_REVIEW = "review";
    /**
     * 状态-再次编辑
     */
    public final static String PHASE_EDIT_AGAIN = "revise";
    /**
     * 状态-格式审核
     */
    public final static String PHASE_FORMAT_AUDIT = "format_audit";
    /**
     * 状态-文件审核
     */
    public final static String PHASE_CONTENT_AUDIT = "audit";
    /**
     * 状态-审批
     */
    public final static String PHASE_APPROVAL = "approve";
    /**
     * 状态-发行
     */
    public final static String PHASE_RELEASE = "release";
    /**
     * 状态-拒绝申请
     */
    public final static String PHASE_REJECT = "reject";
    /**
     * 状态-流程终止
     */
    public final static String PHASE_END = "end";

    /**
     * 状态-取消申请的申请
     */
    public final static String PHASE_CANCEL = "cancel";

    /**
     * 状态-拒绝申请
     */
    public final static String PHASE_REJECT_CANCEL = "reject_cancel";

    /**
     * 状态-同意"取消申请"申请
     */
    public final static String PHASE_AGREE_CANCEL = "agree_cancel";

    public final static Map<Integer, Map<String, String>> phaseMap = new HashMap<>();

    private final static Map<Integer, String> flowName = new HashMap<>();

    static {
        Map<String, String> documentPhaseMap = new HashMap<>();
        Map<String, String> documentPhaseMap3 = new HashMap<>();
        documentPhaseMap.put(PHASE_APPLY, "新增申请");
        documentPhaseMap.put(PHASE_APPLY_APPROVAL, "申请审批");
        documentPhaseMap.put(PHASE_UPLOAD, "上传模板");
        documentPhaseMap.put(PHASE_EDIT, "文件编辑");
        documentPhaseMap.put(PHASE_REVIEW, "文件评审");
        documentPhaseMap.put(PHASE_EDIT_AGAIN, "再次编辑");
        documentPhaseMap.put(PHASE_FORMAT_AUDIT, "格式审核");
        documentPhaseMap.put(PHASE_CONTENT_AUDIT, "文件审核");
        documentPhaseMap.put(PHASE_APPROVAL, "文件审批");
        documentPhaseMap.put(PHASE_RELEASE, "新增发行");
        documentPhaseMap.put(PHASE_REJECT, "拒绝申请");
        documentPhaseMap.put(PHASE_END, "结束");
        documentPhaseMap.put(PHASE_CANCEL, "取消申请");


        documentPhaseMap3.put(PHASE_APPLY, "修订申请");
        documentPhaseMap3.put(PHASE_APPLY_APPROVAL, "申请审批");
        documentPhaseMap3.put(PHASE_UPLOAD, "上传模板");
        documentPhaseMap3.put(PHASE_EDIT, "文件编辑");
        documentPhaseMap3.put(PHASE_REVIEW, "文件评审");
        documentPhaseMap3.put(PHASE_EDIT_AGAIN, "再次编辑");
        documentPhaseMap3.put(PHASE_FORMAT_AUDIT, "格式审核");
        documentPhaseMap3.put(PHASE_CONTENT_AUDIT, "文件审核");
        documentPhaseMap3.put(PHASE_APPROVAL, "文件审批");
        documentPhaseMap3.put(PHASE_RELEASE, "修订发行");
        documentPhaseMap.put(PHASE_REJECT, "拒绝申请");
        documentPhaseMap3.put(PHASE_END, "结束");
        documentPhaseMap3.put(PHASE_CANCEL, "取消申请");

        Map<String, String> documentPhaseMap2 = new HashMap<>();
        documentPhaseMap2.put(PHASE_APPLY, "申请");
        documentPhaseMap2.put(PHASE_CONTENT_AUDIT, "审核");
        documentPhaseMap2.put(PHASE_APPROVAL, "审批");
        documentPhaseMap2.put(PHASE_RELEASE, "发行");
        documentPhaseMap.put(PHASE_REJECT, "拒绝申请");
        documentPhaseMap2.put(PHASE_CANCEL, "取消申请");

        Map<String, String> documentPhaseMap4 = new HashMap<>();
        documentPhaseMap4.put(PHASE_APPLY, "申请");
        documentPhaseMap4.put(PHASE_CONTENT_AUDIT, "审核");
        documentPhaseMap4.put(PHASE_CANCEL, "取消申请");

        flowName.put(FLOW_TYPE_NEW, "新增流程");
        flowName.put(FLOW_TYPE_MODIFY, "修订流程");
        flowName.put(FLOW_TYPE_DROP, "作废流程");
        flowName.put(FLOW_TYPE_DOWNLOAD, "下载打印流程");
        flowName.put(FLOW_TYPE_BORROW, "借阅流程");
        flowName.put(FLOW_TYPE_CANCEL_REQUEST, "取消申请流程");

        phaseMap.put(FLOW_TYPE_NEW, documentPhaseMap);
        phaseMap.put(FLOW_TYPE_MODIFY, documentPhaseMap3);
        phaseMap.put(FLOW_TYPE_DROP, documentPhaseMap2);
        phaseMap.put(FLOW_TYPE_DOWNLOAD, documentPhaseMap2);
        phaseMap.put(FLOW_TYPE_BORROW, documentPhaseMap2);
        phaseMap.put(FLOW_TYPE_CANCEL_REQUEST, documentPhaseMap4);
    }

    public final static String getPhaseName(Integer flowType, String phase) {
        Map<String, String> map = phaseMap.get(flowType);
        if (map != null) {
            return map.get(phase);
        }
        return null;
    }

    public final static String getFlowName(Integer flowType) {
        return flowName.get(flowType);
    }

    public final static String getResult(Integer result) {
        return result == 1 ? "同意" : result == 2 ? "拒绝" : "终止";
    }

}
